/*
 *  (C) Copyright 2008 Insula T.I. Ltda.
 * 
 *  This file is part of Vulcano.
 *
 *  Vulcano is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Lesser General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  Vulcano is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public License
 *  along with Vulcano.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.openinsula.vulcano.orm;

import java.io.Serializable;

import javax.persistence.EntityManager;

import org.hibernate.LazyInitializationException;
import org.hibernate.Session;
import org.openinsula.vulcano.core.command.Command;

/**
 * Callback interface used to initialize persistent beans (provided by Hibernate
 * and JPA, for example). Usually the initialization logic should not be in the
 * command, but we need the {@link Session} or {@link EntityManager} still open,
 * to avoid {@link LazyInitializationException}.
 * 
 * <p>
 * This interface is invoked after {@link Command} execution, but before the
 * {@link Session} or {@link EntityManager} is closed.
 * 
 * @author yanaga
 * 
 * @param <T> The type to be initialized.
 */
public interface InitializingCallback<T> extends Serializable {

	/**
	 * Method that initializes all instances being returned by a {@link Command}.
	 * @param obj The object being initialized.
	 */
	public void init(T obj);

}
